package com.googlecode.ozonbooksfinder.domain
{
	import flexunit.framework.TestCase;

	public class BookTest extends TestCase
	{
		public function testBook ():void
		{
			var book:Book = new Book ();
			
			assertNotNull(book.uid);
			assertTrue(book.uid.length > 0);
			assertFalse(book.isExtendedDetailsAdded);
			
			assertTrue(book.id < 0);
			assertNull(book.name);
			assertNull(book.otherName);
			assertNull(book.author);
			assertTrue(book.year < 0);
			assertNull(book.annotation);
			assertNull(book.imagePath);
			assertNull(book.itemType);
			assertNull(book.date);
			assertTrue(isNaN(book.price));
			assertTrue(book.complekt < 0);
			assertFalse(book.isNew);
			assertNull(book.manufacturer);
			assertTrue(book.pages < 0);
			assertNull(book.isbnCode);
			assertFalse(book.isRecommended);
			assertTrue(book.weight < 0);
			assertNull(book.url);
			assertNull(book.availability);
			assertNull(book.availabilityDate);
			assertTrue(isNaN(book.specialPrice));
			assertTrue(book.hasMerchant < 0);
			assertTrue(book.digitalTypeID < 0);
		}
		
		public function testAddExtendedDetails ():void
		{
			var book:Book = createSimpleBook();
			var extBook:Book = createExtendedBook();
			
			book.addExtendedDetails(extBook);
			
			assertTrue(book.isExtendedDetailsAdded);
			assertFalse(book.uid == extBook.uid);
			assertEquals(book.name, "Test New");
			assertEquals(book.year, 2007);
			assertEquals(book.annotation, "Some annotation");
			assertEquals(book.weight, 1000);
			assertEquals(book.price, 17);
			assertEquals(book.otherName, "Test");
		}
		
		private function createSimpleBook ():Book
		{
			var book:Book = new Book ();
			book.name = "Test";
			book.annotation = "Some annotation";
			book.year = 2006;
			book.weight = 1000;
			book.price = 17;
			return book;
		}
		
		private function createExtendedBook ():Book
		{
			var book:Book = new Book ();
			book.name = "Test New";
			book.year = 2007;
			book.otherName = "Test";
			book.annotation = "";
			return book;
		}
	}
}